package org.yray.sip.creator;

import org.yray.sip.base.MsgEle;
import org.yray.sip.server.SipSession;

public class ForbiddenCreator extends MessageCreator{


    /***
     * SIP/2.0 403 Forbidden
     * Via: SIP/2.0/UDP 192.168.44.84:56823;rport=56823;branch=z9hG4bKPjafd8ff82765c42fd93594d7008ce5842
     * From: "99996" <sip:99996@172.40.1.62>;tag=f40bb74caf69465ab54cae30e8f6e0e7
     * To: "99996" <sip:99996@172.40.1.62>;tag=2HS15aKtgSD4a
     * Call-ID: 383b15acdb7043ddb762d7120e4ebae9
     * CSeq: 34669 REGISTER
     * User-Agent: OE+ PBX
     * Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
     * Supported: path, replaces
     * Content-Length: 0
     * @param session
     * @return
     */
    @Override
    public String createMsg(SipSession session) {
        StringBuilder sb = new StringBuilder();
        sb.append("SIP/2.0 403 Forbidden").append(MsgEle.LINE_SEPARATOR);
        sb.append("Via: SIP/2.0/UDP "+ session.getLocalIpPort()+";rport;branch="+session.getBranch()).append(MsgEle.LINE_SEPARATOR);
        sb.append("From: "+session.getSipExtIpName()+";tag="+session.getTag()).append(MsgEle.LINE_SEPARATOR);
        sb.append("To: "+session.getSipExtIpName()).append(MsgEle.LINE_SEPARATOR);
        sb.append("Call-ID: "+session.getCallId()).append(MsgEle.LINE_SEPARATOR);
        sb.append("CSeq: "+session.getCseq()+" REGISTER").append(MsgEle.LINE_SEPARATOR);
        sb.append("User-Agent: ROBOT NO1").append(MsgEle.LINE_SEPARATOR);
        sb.append("Contact: "+session.getContact()).append(MsgEle.LINE_SEPARATOR);
        sb.append("Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE").append(MsgEle.LINE_SEPARATOR);
        sb.append("Supported: path, replaces").append(MsgEle.LINE_SEPARATOR);
        sb.append("Content-Length:  0").append(MsgEle.LINE_SEPARATOR);
        sb.append(MsgEle.LINE_SEPARATOR);
        return sb.toString();
    }
}
